local InputMgr = class("InputMgr");
function InputMgr:ctor()
    self._lockers = {};
    self._lockerCnt = 0;
    self._sch = nil;
end

function InputMgr:lock(lockType,lockTime)
    lockTime = lockTime or 99999999900;
    if self._lockers[lockType] then
        self._lockers[lockType] = self._lockers[lockType] + lockTime;
    else
        self._lockers[lockType] = lockTime;
        self._lockerCnt = self._lockerCnt + 1;
        if self._lockerCnt == 1 then
            local ly = mgrs.wnd:getLayer(enums.Layer.Locker);
            ly:setTouchEnabled(true);
        end
    end

    if not self._sch then
        self._sch = mgrs.scheduler:scheduleGlobal(function()
            for key, var in pairs(self._lockers) do
                self._lockers[key] = var - 0.1 * 1000;
                if self._lockers[key] <= 0 then
                    self:unLock(key);
                end
            end
        end,0.1)
    end
end

function InputMgr:unLock(lockType)
    mgrs.log:printNotice("unLockType = %s",lockType)
    if self._lockers[lockType] then
        self._lockers[lockType] = nil;
        self._lockerCnt = self._lockerCnt - 1;
        if self._lockerCnt <= 0 then
            local ly = mgrs.wnd:getLayer(enums.Layer.Locker);
            ly:setTouchEnabled(false);
            mgrs.scheduler:unscheduleGlobal(self._sch);
            self._sch = nil;
        end
    else
        mgrs.log:printNotice("InputMgr unLock lockType = %s not found",lockType);
    end
end

mgrs.input = nil;
mgrs.singleClass(mgrs,InputMgr,"input");


--endregion
